{% extends "openvolunteer/base.html" %}

{% block title %}OpenVolunteer | Chercher les bénévoles ayant occupé ce poste: {{job}} depuis le {{ limit|date:"d F Y" }}{% endblock %}

{% block content %}
    <div class="search-results">
        {% if volunteers %}
            <table id="resultsTable">
                <tr>
                    <th>Nom</th>
                    <th>Prénom</th>
                    <th>Email</th>
                    <th>Téléphone fixe</th>
                    <th>Mobile</th>
                    <th>Adresse</th>
                    <th>Date de naissance</th>
                    <th>Lieu de naissance</th>
                    <th>Numéro de sécu</th>
                    <th>Première inscription</th>
                    <th>CA ?</th>
                </tr>
                {% for volunteer in volunteers %}
                    <tr>
                        <td>{{ volunteer.name }}</td>
                        <td>{{ volunteer.firstname }}</td>
                        <td>
                            {% if volunteer.email %}
                                {{ volunteer.email }}&nbsp;
                                <a href="mailto:{{ volunteer.email }}" title="Envoyer un email">
                                    <img src="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/files/icons/email.png" alt="mail" class="icon">
                                </a>
                            {% endif %}
                        </td>
                        <td>{{ volunteer.phone_home }}</td>
                        <td>{{ volunteer.phone_mobile }}</td>
                        <td>{{ result.address }}</td>
                        <td>{{ result.birthday|date:"d F Y"  }}</td>
                        <td>{{ result.birth_place }}</td>
                        <td>
                            {% if result.social_security_number %}
                                {{ result.social_security_number }}
                            {% endif %}
                        </td>
                        <td>{{ result.inscription_date|date:"d F Y" }}</td>
                        <td style="text-align:center;">
                            {% if volunteer.ca_member %}
                                <img src="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/files/icons/yes.png" alt="oui" class="icon">
                            {% else %}
                                <img src="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/files/icons/no.png" alt="non" class="icon">
                            {% endif %}
                        </td>
                        <td class="more">
                            <a href="{{ volunteer.get_absolute_url }}"
                               title="Consulter la fiche détaillée de {{ result }}">
                               Fiche détaillée
                            </a>
                        </td>
                    </tr>
                {% endfor %}
            </table>
            <div id="dialog_cols_mgt" title="Afficher ou cacher des colonnes" style="text-align:center;">
                <ul id="toogleColsList" class="toogleColsList"></ul>
            </div>
            <script src="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/files/jquery/plugins/jquery.cookie.js"></script>
            <script src="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/files/jquery/plugins/jquery.columnmanager.js"></script>
            <script type="text/javascript">
                $(function() {
                    $('#resultsTable').columnManager({
                        onClass: 'displayed',
                        offClass: 'hidden',
                        listTargetID:'toogleColsList',
                        saveState: true,
                        colsHidden: [6, 7, 8, 9, 10],
                        show: function(c) {
                            $(c).fadeIn(1000);
                        },
                        hide: function(c){
                            $(c).fadeOut(1000);
                        }
                    });

                    $("#dialog_cols_mgt").dialog({
                        bgiframe: true,
                        draggable: true,
                        width:400,
                        modal: true,
                        autoOpen: false
                    });
                });
            </script>
        {% else %}
            <div class="search-error">
                <p>Aucune réponse positive n'a été trouvée pour ce poste ({{ job }}) depuis le {{ limit|date:"d F Y" }}.</p>
            </div>
        {% endif %}
    </div>
{% endblock %}

{% block navigation %}
    <ul>
        {% if volunteers %}
            <li>
                <a href='{{ settings.OPENVOLUNTEER_MEDIA_URL }}/csv/volunteer_list.csv' title="Télécharger la liste générée">
                    Télécharger la liste générée
                </a>
            </li>
            <li>
                <a href="javascript:;" onclick="$('#dialog_cols_mgt').dialog('open');">Afficher ou cacher les colonnes</a>
            </li>
        {% endif %}
        <li>
            <a href="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/job/" title="Liste des postes">
                Liste des postes
            </a>
        </li>
        <li>
            <a href="{{ settings.OPENVOLUNTEER_WEB_ROOT }}/volunteer/" title="Chercher un bénévole">
                Chercher un bénévole
            </a>
        </li>
    </ul>
{% endblock %}
